const path = require('path')
const CompressionPlugin = require("compression-webpack-plugin")
module.exports = {
  publicPath: '/',
  productionSourceMap: false,
  lintOnSave: true,
  devServer: {
      port: 80,
      host: '0.0.0.0',
      open: false,
      proxy: {
          '/api': {
              target: 'http://admin.yaque365.com',
              ws: false,
              changeOrigin: true,
              pathRewrite: {
                '^/api': ''
              } 
          }
      },
      disableHostCheck: true
  },
  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'less',
      patterns: path.resolve(__dirname, './src/css/common.less')
    },
  },
  configureWebpack: () => {
    if (process.env.NODE_ENY === 'production') {
      return {
        plugins: [
          new CompressionPlugin({
            text: /\.js$|\.html$|\.css/,
            threshold: 10240,
            deleteOrighinalAssets: false
          })
        ],
        externals: {
          'v-charts': 'VeIndex',
          'md5': 'md5'
        }
      }
    } else {
      return {
        externals: {
          'v-charts': 'VeIndex',
          'md5': 'md5'
        }
      }
    }
  },
  css: {
    loaderOptions: {
      stylus: {
        'resolve url': true,
        'import': [
          './src/theme'
        ]
      }
    }
  }
}
